<!--
 * @Author: wangding
 * @Date: 2020-11-06 16:33:50
 * @LastEditTime: 2020-11-06 16:45:53
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\overview-inverter\alarm\proposal.vue
-->
<template>
    <div>
        <el-dialog
        :title="$t('remark')"
        :visible="visibleShow2"
        width="650px"
        @opened="showData"
        @close="close"
        >
            <el-form ref="form" :model="form" label-width="200px">
                <el-form-item :label="$t('remark')">
                    <el-input v-model="form.remark" type="textarea" :placeholder="$t('remark')" style="width: 300px;"></el-input>
                </el-form-item>
                <el-form-item :label="$t('Last_process_time')+'(UTC)'">
                    <span>{{form.handleTime||'-'}}</span>
                </el-form-item>
                <el-form-item>
                    <el-radio-group  v-model="form.status" size="mini">
                        <el-radio :label="0" border>{{$t('Untreated')}}</el-radio>
                        <el-radio :label="1" border>{{$t('Treated')}}</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="()=>{$store.commit('setVisibleShow2',false)}">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="save('form')">{{$t('sure')}}</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
    components: {

    },
    props: {
        inverterSn:{
            type:String,
            default:() =>{return ''}
        },
        handleData:{
            type:Object,
            default:() =>{return {}}
        }
    },
    data() {
        return {
            form:{
                inverterSn:'',
                remark:'',
                status:0,
                handleTime:''
            },
        };
    },
    computed: {
        visibleShow2(){
            return this.$store.state.sysStore.visibleShow2
        }
    },
    watch: {
    },
    created() {

    },
    mounted() {
        
    },
    methods: {
        close(){
            this.form={
                inverterSn:'',
                remark:'',
                status:0,
                handleTime:''
            }
            this.$store.commit('setVisibleShow2',false)
        },
        showData(){
            this.form = this.handleData
        },
        async devalarmhandleSave(){
            let res = await this.API.devalarmhandleSave({
                inverterSn:this.inverterSn,
                remark:this.form.remark,
                status:this.form.status,
            })
            if(res.success){
                this.$message({
                    message: this.$t('index.control_success'),
                    type: 'success'
                });
                this.$store.commit('setVisibleShow2',false)
                this.$emit('uploadData',true)
            }else{
                this.$message({
                    message: this.$t('index.control_fail'),
                    type: 'warning'
                });
            }
        },
        save(formName){
            this.$refs[formName].validate((valid) => {
              if (valid) {
                  this.devalarmhandleSave()
              } else {
                console.log('error submit!!');
                return false;
              }
            });
        },
    },
};
</script>

<style  lang="less" scoped>
.proposal-main-box{
    .big-box{
        line-height: 30px;
        span{
            font-weight: bold;
        }
        p{
            margin: 0;
            color: #6b6b6b;
            line-height: 20px;
            font-size: 13px;
        }
    }
}
</style>
